home *** CD-ROM | disk | FTP | other *** search
- class Tips extends MovieClip
- {
- var txt;
- var inner;
- var queue;
- var showFor;
- var mode;
- var shownFor;
- static var BASE_WAIT = 15;
- static var CHAR_WAIT = 2.2;
- static var IDLE = "idle";
- static var SHOWING = "showing";
- static var TRANSITIONING = "transitioning";
- static var SHOW = "show";
- static var HIDE = "hide";
- static var NEW = "new";
- function Tips()
- {
- super();
- this.txt = this.inner.txt;
- this.queue = [];
- }
- function addMessage(str)
- {
- this.queue.push(str);
- }
- function checkMessages()
- {
- if(this.queue.length)
- {
- this.setMessage();
- }
- }
- function setMessage()
- {
- this.txt.text = String(this.queue.shift());
- this.showFor = Tips.BASE_WAIT + this.txt.text.length * Tips.CHAR_WAIT;
- this.gotoAndPlay(Tips.SHOW);
- this.mode = Tips.TRANSITIONING;
- }
- function showingMessage()
- {
- this.mode = Tips.SHOWING;
- this.shownFor = 0;
- this.inner.gotoAndPlay(Tips.NEW);
- this.stop();
- }
- function hidingMessage()
- {
- this.gotoAndPlay(Tips.HIDE);
- delete this.shownFor;
- this.mode = Tips.TRANSITIONING;
- }
- function hiddenMessage()
- {
- this.mode = Tips.IDLE;
- this.stop();
- }
- function update()
- {
- if(this.mode == Tips.SHOWING)
- {
- if(++this.shownFor >= this.showFor)
- {
- this.hidingMessage();
- }
- }
- else if(this.mode == Tips.IDLE)
- {
- this.checkMessages();
- }
- }
- }
-